package com.xiangban.yanglaodajie_admin.controller;


import com.xiangban.yanglaodajie_admin.aop.Permission;
import com.xiangban.yanglaodajie_admin.entity.ClassOrActivity;
import com.xiangban.yanglaodajie_admin.entity.ClassSchedule;
import com.xiangban.yanglaodajie_admin.entity.Ids;
import com.xiangban.yanglaodajie_admin.entity.OrdersClassOrActivity;
import com.xiangban.yanglaodajie_admin.entity.dto.ClassOrActivityDto;
import com.xiangban.yanglaodajie_admin.entity.dto.ClassScheduleDto;
import com.xiangban.yanglaodajie_admin.entity.res.ApiResult;
import com.xiangban.yanglaodajie_admin.service.ClassOrActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * @Author Mr. MaYaYun
 * @Data 2021/6/9 16:06
 */
@RestController
@RequestMapping("/api/admin/class_activity")
@Api(tags = "课程管理")
public class ClassOrActivityController {

    @Autowired
    private ClassOrActivityService classOrActivityService;

    @PostMapping("/getClassActivityList")
    @ApiOperation("课程列表")
    @Permission(permission = "admin:class_activity:getClassActivityList")
    public ApiResult<Object> getClassActivityList(@RequestBody ClassOrActivityDto classOrActivityDto) {
        return ApiResult.newSuccess(classOrActivityService.getClassActivityList(classOrActivityDto));
    }

    @PostMapping("/getClassActivityInfo")
    @ApiOperation("课程详情")
    @Permission(permission = "admin:class_activity:getClassActivityInfo")
    public ApiResult<Object> classActivityInfo(@RequestBody ClassOrActivity classOrActivity) {
        return ApiResult.newSuccess(classOrActivityService.classActivityInfo(classOrActivity));
    }


    @PostMapping("/addClassActivity")
    @ApiOperation("课程添加")
    @Permission(permission = "admin:class_activity:addClassActivity")
    public ApiResult<Object> addClassActivity(@RequestBody ClassOrActivity classOrActivity) {
        classOrActivityService.addClassActivity(classOrActivity);
        return ApiResult.newSuccess();
    }

    @PostMapping("/getClassActivityTime")
    @ApiOperation("上课时间详情")
    @Permission(permission = "admin:class_activity:getClassActivityTime")
    public ApiResult<Object> getClassActivityTime(@RequestBody ClassScheduleDto classScheduleDto) {
        return ApiResult.newSuccess(classOrActivityService.getClassActivityTime(classScheduleDto));
    }

    @PostMapping("/addClassActivityTime")
    @ApiOperation("上课时间添加")
    @Permission(permission = "admin:class_activity:addClassActivityTime")
    public ApiResult<Object> addClassActivityTime(@RequestBody ClassScheduleDto classScheduleDto) throws ParseException {
        classOrActivityService.addClassActivityTime(classScheduleDto);
        return ApiResult.newSuccess();
    }

    @PostMapping("/updateClassActivityTime")
    @ApiOperation("上课时间修改")
    @Permission(permission = "admin:class_activity:updateClassActivityTime")
    public ApiResult<Object> updateClassActivityTime(@RequestBody ClassScheduleDto classScheduleDto) throws ParseException {
        classOrActivityService.updateClassActivityTime(classScheduleDto);
        return ApiResult.newSuccess();
    }

    @PostMapping("/deleteClassActivityTime")
    @ApiOperation("上课时间删除")
    @Permission(permission = "admin:class_activity:deleteClassActivityTime")
    public ApiResult<Object> deleteClassActivityTime(@RequestBody ClassSchedule classSchedule) {
        classOrActivityService.deleteClassActivityTime(classSchedule);
        return ApiResult.newSuccess();
    }

    @PostMapping("/updateClassActivity")
    @ApiOperation("课程修改")
    @Permission(permission = "admin:class_activity:updateClassActivity")
    public ApiResult<Object> updateClassActivity(@RequestBody ClassOrActivity classOrActivity) {
        classOrActivityService.updateClassActivity(classOrActivity);
        return ApiResult.newSuccess();
    }

    @PostMapping("/deleteClassActivity")
    @ApiOperation("课程删除")
    @Permission(permission = "admin:class_activity:deleteClassActivity")
    public ApiResult<Object> deleteClassActivity(@RequestBody Ids ids) {
        classOrActivityService.deleteClassActivity(ids);
        return ApiResult.newSuccess();
    }


//    @PostMapping("/shopIncome")
//    @ApiOperation("课程学员")
//    public ApiResult<Object> classActivityStudents(){
//        classifyGoodsService
//    }
}
